<!DOCTYPE html>
<html lang="en">
<head>
	#parse("head.html")
	<title>Login</title>
</head>
<body>

<div class="container">
	<div class="row">
		<div class="col-xs-offset-2">
			<h1>欢迎您登录</h1>
		</div>
	</div>
	<div class="row" id="login">
		<div class="col-md-6">
			<form class="form-horizontal">
				<div class="form-group">
					<label for="inputEmail3" class="col-sm-2 control-label">用户名</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" id="inputEmail3" placeholder="用户名" name="username">
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">密码</label>
					<div class="col-sm-10">
						<input type="password" class="form-control" id="inputPassword3" placeholder="密码" name="password">
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">密码</label>
					<div class="col-sm-10">
						<input type="code" class="form-control" id="code" placeholder="验证码" name="code">
						<img id="imgCode" src="$WEB_PATH/user/captcha" alt="" />
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						<div class="checkbox">
							<label>
								<input type="checkbox" value="1" name="rememberMe"> 记住我
							</label>
						</div>
					</div>
				</div>
			</form>
##			此时的button需要放在form外面，不然会出现乱七八糟的bug
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button id="loginBtn" class="btn btn-default">登录</button>
					<a class="glyphicon btn btn-info" href="${WEB_PATH}/registPre">用户注册</a>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
##	action="$WEB_PATH/user/login" method="post"
	$(document).ready(function(){
		var count = 0 ;
		$("#loginBtn").on("click",function () {
			$.ajax({
				url:"${WEB_PATH}/user/login",
				data:$("#login form").serialize(),
				type:"POST",
				success:function (data) {
					if(data.code==1){
						alert(data.msg) ;
						window.location="${WEB_PATH}/" ;
					}else if(data.code==2){
						alert(data.msg) ;
					}
				}
			}) ;
		}) ;
		$("#imgCode").on("click",function(){

		    var url = "$WEB_PATH/user/captcha?count="+ count++;
		   	$(this).attr("src",url) ;
		}) ;
	});
</script>
</body>
</html>